package com.yvdedu.hospital.controller;


import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.yvdedu.hospital.entity.Drug;
import com.yvdedu.hospital.entity.Drug_type;
import com.yvdedu.hospital.entity.Used;
import com.yvdedu.hospital.service.DepotDailyService;


@Controller
@RequestMapping("business/depot/statistics")
public class DepotStatisticsController {
	@Resource
	DepotDailyService depotDailyService;
	List<Drug> Drug;
	List<Used> used;
	List<Drug_type> drug_type;
	
//	药品综合查询
	@RequestMapping("yp_query")
	public String drugadmin(Integer pageNumber, Model model){
		System.out.println(pageNumber);
		if(pageNumber==null){
			pageNumber=1;
		}
		Drug=depotDailyService.drugQuery((int)pageNumber);
		PageInfo page = new PageInfo(Drug);
		model.addAttribute("pageNumber",page.getPageNum());
		model.addAttribute("Pages",page.getPages());
		model.addAttribute("drugadmin", Drug);
		return "business/depot/statistics/yp_query";
		
	}
	//药品时间范围查询
	@RequestMapping("searchData")
	public String data_query(Drug drug,@Param("sc_date") String sc_date,@Param("yx_date") String yx_date,@Param("name") String name, Model model){
		Drug=depotDailyService.DateMax_DateMinx(sc_date, yx_date,name);
		drug.setSc_date(sc_date);
		drug.setYx_date(yx_date);
		drug.setName(name);
		model.addAttribute("drugadmin", Drug);
		return "business/depot/statistics/yp_query";
		
	}
	
//	药品销售查询
	@RequestMapping("yp_sale")
	public String zy_medicine(Integer pageNumber,Model model){
		System.out.println(pageNumber);
		if(pageNumber==null){
			pageNumber=1;
		}
		System.out.println(pageNumber);
		used=depotDailyService.CommonYao(pageNumber);
		System.out.println(used);
		PageInfo page = new PageInfo(used);
		model.addAttribute("pageNumber",page.getPageNum());
		model.addAttribute("Pages",page.getPages());
		model.addAttribute("yp_saleList", used);
		return "business/depot/statistics/yp_sale";
		
	}
	//药品销售查询药品时间范围查询
		@RequestMapping("fw_searchData")
		public String fw_searchData(Drug drug,@Param("sc_date") String sc_date,@Param("yx_date") String yx_date,@Param("name") String name, Model model){
			used=depotDailyService.CommonYao_data(sc_date, yx_date,name);
			drug.setSc_date(sc_date);
			drug.setYx_date(sc_date);
			drug.setName(name);
			System.out.println(used);
			System.out.println(sc_date);
			System.out.println(sc_date);
			System.out.println(name);
			model.addAttribute("yp_saleList", used);
			return "business/depot/statistics/yp_sale";
			
		}
//	药品各类总汇
	@RequestMapping("yp_typesum")
	public String bill(Integer pageNumber,Model model){
		
		System.out.println(pageNumber);
		if(pageNumber==null){
			pageNumber=1;
		}
		System.out.println(pageNumber);
		drug_type=depotDailyService.hz_Query(pageNumber);
		System.out.println(drug_type);
		PageInfo page = new PageInfo(drug_type);
		model.addAttribute("pageNumber",page.getPageNum());
		model.addAttribute("Pages",page.getPages());
		model.addAttribute("yp_typesum", drug_type);
		return "business/depot/statistics/yp_typesum";
		
	}
//药品 药品类型 时间 名字查询
	@RequestMapping("yp_typesum_search")
	public String yp_typesum_search(Drug_type type,@Param("sc_date") String sc_date,@Param("yx_date") String yx_date,@Param("name") String name,@Param("yao_name") String yao_name,Model model){
		drug_type=depotDailyService.yp_typesum_search(sc_date,yx_date,name,yao_name);
		System.out.println(drug_type);
		System.out.println(sc_date);
		System.out.println(yx_date);
		System.out.println(name);
		System.out.println(yao_name);
		type.setSc_date(sc_date);
		type.setYx_date(yx_date);
		type.setName(name);
		type.setYao_name(yao_name);
		model.addAttribute("yp_typesum", drug_type);
		return "business/depot/statistics/yp_typesum";
		
	}
	
	
//	药品调价总汇
	@RequestMapping("yp_pricesum")
	public void drugadmin(){
	}
	

}

